﻿using System;
using Caffeine.Core;
using Caffeine.Wpf;

namespace Caffeine.Examples.Contacts.ViewModel
{
    public class CommitFormCommand : ViewModelCommand
    {
        public CommitFormCommand(ViewModelBase parent)
            : base(parent)
        {
        }

        protected override Boolean OnCanExecute(Object parameter)
        {
            return Parent.IsDirty && !Parent.IsInvalid;
        }

        protected override void OnExecute(Object parameter)
        {
            Parent.Commit();
        }
    }
}
